package com.lagou.edu.mvcframework.servlet;

import com.lagou.edu.mvcframework.pojo.Handler;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;

/**
 * @author 陶肖寅
 * @version V1.0
 * @Package com.lagou.edu.mvcframework.servlet
 * @date 2020-02-01 13:55
 * @Copyright © 2020-2021 城云科技(中国)有限公司
 */
public class Test {
    public static void main(String[] args) {
        Handler handler = new Handler();
//        handler.getParamIndexMapping().put("name",1);
//        System.out.println(handler.getParamIndexMapping().containsKey("name"));
        //计算参数位置
        try {
            Class<?> clzz = Class.forName("com.lagou.edu.mvcframework.controller.DemoController");
            Method[] methods = clzz.getDeclaredMethods();
            System.out.println("method size:"+methods.length);
            for (Method method : methods) {
                Parameter[] parameters = method.getParameters();
                for (Parameter parameter : parameters) {
                    //参数名
                    System.out.println("\t\t" + parameter.getName());
                    //是否在源码中隐式声明的参数名
                    System.out.println("\t\t\t implicit:" + parameter.isImplicit());
                    //类文件中，是否存在参数名
                    System.out.println("\t\t\t namePresent:" + parameter.isNamePresent());
                    //是否为虚构参数
                    System.out.println("\t\t\t synthetic:" + parameter.isSynthetic());
                    System.out.println("\t\t\t VarArgs:" + parameter.isVarArgs());
                }

            }

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }
}
